package com.gz.moreaseManager.modules.service.impl;

import com.gz.moreaseManager.core.base.Constants;
import com.gz.moreaseManager.modules.entity.Content;
import com.gz.moreaseManager.modules.mapper.ContentMapper;
import com.gz.moreaseManager.modules.service.IContentService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.gz.moreaseManager.utils.UtilTool;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 合作内容信息 服务实现类
 * </p>
 *
 * @author wike
 * @since 2019-02-26
 */
@Service
public class ContentServiceImpl extends ServiceImpl<ContentMapper, Content> implements IContentService {

    @Resource
    private ContentMapper contentMapper;

    /***
    * @author :ganzheng
    * @Description: 获取内容信息
    * @date 14:14 2019/3/8
    * @return
    */
    private List<Content> findContentByAuthCode( String authCode ){
        if(UtilTool.isNotBlank( authCode )){
            List<Content> contentList  = contentMapper.findContentByAuthCode( authCode );
            if( UtilTool.isNotBlank( contentList ))
                return contentList;
        }
        return null;
    }


    /**
     * 获取加盟政策
     * @return
     */
    public Content findContentPolicy(){
        List<Content> list = findContentByAuthCode(Constants.HE_TYPE_AFFILIATE_POLICY);
        if( UtilTool.isNotBlank( list  ) && list.size() == 1 )
            return list.get(0);
        return null;
    }

    /**
     * 获取门面效果政策
     * @return
     */
    public Content findContentStoreEffect(){
        List<Content> list = findContentByAuthCode(Constants.HE_TYPE_STORE_EFFECT);
        if( UtilTool.isNotBlank( list  ) && list.size() == 1 )
            return list.get(0);
        return null;
    }

    /**
     * 获取人才合作
     * @return
     */
    public Content findContentPersonRecruit(){
        List<Content> list = findContentByAuthCode(Constants.HE_TYPE_PERSONNEL);
        if( UtilTool.isNotBlank( list  ) && list.size() == 1 )
            return list.get(0);
        return null;
    }
}
